import sys
import os
from java.lang import System

import getopt

def usage():
    print "Usage:"
    print "createJMSModule [-n] -u user -c credential -h host -p port -s serverName -m moduleName [-d subDeploymentName] -j jmsServerName"

try:
    opts, args    = getopt.getopt(sys.argv[1:], "nu:c:h:p:s:m:d:j:",
                                  ["user=", "credential=", "host=", "port=",
                                   "targetServerName=", "moduleName=",
                                   "subDeploymentName=", "jmsServerName="])
except getopt.GetoptError, err:
    print str(err)
    usage()
    sys.exit(2)

reallyDoIt  = true
user        = ''
credential  = ''
host        = ''
port        = ''
targetServerName  = ''
moduleName  = ''
subDeploymentName   = 'DeployToJMSServer'
jmsServerName   = ''

for opt, arg in opts:
    if opt == "-n":
        reallyDoIt  = false
    elif opt == "-u":
        user        = arg
    elif opt == "-c":
        credential  = arg
    elif opt == "-h":
        host        = arg
    elif opt == "-p":
        port        = arg
    elif opt == "-s":
        targetServerName  = arg
    elif opt == "-m":
        moduleName  = arg
    elif opt == "-d":
        subDeploymentName   = arg
    elif opt == "-j":
        jmsServerName   = arg
        
if user == "":
    print "Missing \"-u user\" parameter."
    usage()
    sys.exit(2)
elif credential == "":
    print "Missing \"-c credential\" parameter."
    usage()
    sys.exit(2)
elif host == "":
    print "Missing \"-h host\" parameter."
    usage()
    sys.exit(2)
elif port == "":
    print "Missing \"-p port\" parameter."
    usage()
    sys.exit(2)
elif targetServerName == "":
    print "Missing \"-s serverName\" parameter."
    usage()
    sys.exit(2)
elif moduleName == "":
    print "Missing \"-m moduleName\" parameter."
    usage()
    sys.exit(2)
elif jmsServerName == "":
    print "Missing \"-j jmsServerName\" parameter."
    usage()
    sys.exit(2)

print "Got all the required parameters"